﻿package plugin.npcDialog.ui.panels.active
{
    import cmd.*;
    import flash.events.*;
    import manager.*;
    import morn.core.handlers.*;
    import plugin.instance.*;
    import pluginfw.nio.*;
    import uiresource.npcdialogs.*;
    import view.mornExtends.*;
    import vo.*;

    public class ActiveEnter extends YxFMGUI implements INpcDialogContent
    {
        private var _rews:Array;
        private var _data:Object;

        public function ActiveEnter()
        {
            this._rews = new Array();
            return;
        }// end function

        public function close() : void
        {
            if (this.parent)
            {
                this.parent.removeChild(this);
            }
            return;
        }// end function

        override protected function initializeView() : void
        {
            super.initializeView();
            btn_jinru.addEventListener(MouseEvent.CLICK, this.btnClickHandler);
            list.renderHandler = new Handler(this.listRenderHandler);
            return;
        }// end function

        private function listRenderHandler(param1:FlashItem, param2:int) : void
        {
            if (param2 < list.array.length)
            {
                param1.data = list.array[param2];
            }
            return;
        }// end function

        public function show(param1:Object, param2:Object) : void
        {
            var _loc_6:String = null;
            var _loc_7:Object = null;
            var _loc_3:* = ConfigDictionary.data.intoinstance;
            this._data = _loc_3[param1.npcid];
            var _loc_4:* = ConfigDictionary.data.item;
            param2.titletxt.text = this._data.title;
            this._rews = [];
            var _loc_5:* = this._data.rewards.split("#");
            for each (_loc_6 in _loc_5)
            {
                
                _loc_7 = ItemObject.create(_loc_4[_loc_6]);
                this._rews.push(_loc_7);
            }
            list.array = this._rews;
            this.label_shuom.text = this._data.desc;
            return;
        }// end function

        private function btnClickHandler(event:Event = null) : void
        {
            var _loc_2:Object = null;
            var _loc_3:Output = null;
            if (this._data.mapid > 10000)
            {
                PluginManager.instance.sendToServer("instance", CMDInstance.NpcInstance, {mapid:this._data.mapid});
            }
            else
            {
                _loc_2 = ConfigDictionary.data.deliver[this._data.npcid][0];
                _loc_3 = new Output();
                _loc_3.writeVarInt(_loc_2.stageid, false);
                _loc_3.writeVarInt(_loc_2.x, false);
                _loc_3.writeVarInt(_loc_2.y, false);
                PluginManager.instance.sendToBufferServer("activity", CMDActivity.IntoBossInstance, _loc_3);
            }
            return;
        }// end function

        public function update(param1:Object, param2:int = 0) : void
        {
            return;
        }// end function

    }
}
